#include <bits/stdc++.h>

using namespace std;

int main(int argc, char const *argv[])
{
	int N;scanf("%d",&N);
	std::vector<long long> sum(N),isdrop(N);
	for (int i = 0; i < N; ++i)
	{
		int m;scanf("%d",&m);
		for (int j = 0; j < m; ++j)
		{
			long long a;scanf("%lld",&a);
			if(a>0){
				if(sum[i]>a){
					isdrop[i]=1;
					// printf("tree is %d, time is %d\n", i,j);
				}
				sum[i]=a;
			}else if(a<=0){
				sum[i]+=a;
			}
		}
	}
	long long ans=0,cnt=0,consecutive=0;
	for (int i = 0; i < N; ++i)
	{
		ans+=sum[i];
		if(isdrop[i]==1){
			++cnt;
			if(isdrop[(i+1)%N]&&isdrop[(i+2)%N]){
				++consecutive;
			}
		}
	}
	printf("%lld %lld %lld\n", ans,cnt,consecutive);

	return 0;
}